const path = require('path') // 路径
var HtmlWebpackPlugin = require('html-webpack-plugin'); // 解析html

// 相对路径转换绝对路径
const resolvePath = _path => path.resolve(__dirname, _path)

module.exports = {
    entry: resolvePath('../src/index.js'),
    output: {
        path: resolvePath('../dist'),
        filename: '[name].boundle.js',
    },
    mode:'development', 
    devtool:'inline-source-map',
    devServer: {
        host:'127.0.0.1',
        port: 9000,
        hot:true,
        open:true,
        proxy:{
            '/api':{
                target: "http://127.0.0.1:8888",
                // pathRewrite: {"^/api" : ""}
            }
        }
      },
    plugins: [
        new HtmlWebpackPlugin({
            template: resolvePath('../public/index.html'),
            filename: 'index.html',
            title: '热更新',
        }),
    ]
}
